<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>Add Course</title>
        </h:head>

        <h:body>
            <p:layout fullPage="true">
                <p:layoutUnit position="north" header="EducationX">
                    <p:toolbar style="height:25px">
                        <p:toolbarGroup align="left">
                            <h:link value="Courses" outcome="courses"/>     
                            <p:separator />  
                            <h:link value="User Page" outcome="userPage" />
                            <p:separator />  
                            <h:link value="Tags" />
                        </p:toolbarGroup>
                    </p:toolbar>
                </p:layoutUnit>

                <p:layoutUnit position="center" size="300">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                    <h1>New Course</h1>
                    <h:form>
                        <h:panelGrid columns="2">
                            <h:outputText value="Name:"/>
                            <h:inputText id="name" value="#{courses.course.name}" title="Name" required="true" requiredMessage="The name field is required." />

                            <h:outputText value="Status" />
                            <h:selectOneRadio value="#{courses.course.status}">
                                <f:selectItem itemValue="A" itemLabel="Open" />
                                <f:selectItem itemValue="P" itemLabel="Closed" />
                            </h:selectOneRadio>

                            <h:outputText value="Description:"/>
                            <h:inputTextarea id="description" value="#{courses.course.description}" title="Description" required="true" requiredMessage="The description field is required." validatorMessage="description is not valid" />

                            <h:outputText value="Tags:"/>
                            <h:inputTextarea id="tags" title="Tags" required="true" requiredMessage="The tag field is required." validatorMessage="tag is not valid" />

                        </h:panelGrid>

                        <br />
                        <h:commandButton action="#{courses.create}" value="Create a new course">
                            <f:setPropertyActionListener target="#{courses.action}" value="#{user.user}" />
                        </h:commandButton>
                    </h:form>
                </p:layoutUnit>
            </p:layout>
        </h:body>
    </f:view>
</html>
